summaryrefslogtreecommitdiff
path: root/app/[lng]/evcp/(evcp)/rfq-last/[id]/page.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'app/[lng]/evcp/(evcp)/rfq-last/[id]/page.tsx')
-rw-r--r--app/[lng]/evcp/(evcp)/rfq-last/[id]/page.tsx140
1 files changed, 79 insertions, 61 deletions
diff --git a/app/[lng]/evcp/(evcp)/rfq-last/[id]/page.tsx b/app/[lng]/evcp/(evcp)/rfq-last/[id]/page.tsx
index 1ccb7559..82f9fc4c 100644
--- a/app/[lng]/evcp/(evcp)/rfq-last/[id]/page.tsx
+++ b/app/[lng]/evcp/(evcp)/rfq-last/[id]/page.tsx
@@ -1,26 +1,24 @@
import { Separator } from "@/components/ui/separator"
-import { type SearchParams } from "@/types/table"
-import { getValidFilters } from "@/lib/data-table"
-import { searchParamsRfqAttachmentsCache } from "@/lib/b-rfq/validations"
-import { getRfqLastAttachments } from "@/lib/rfq-last/service"
+import { getRfqAllAttachments, getRfqVendorAttachments } from "@/lib/rfq-last/service"
import { RfqAttachmentsTable } from "@/lib/rfq-last/attachment/rfq-attachments-table"
import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"
-import { AlertCircle } from "lucide-react"
+import { AlertCircle, ArrowLeft, ArrowRight } from "lucide-react"
+import { Card, CardContent,CardDescription ,CardHeader ,CardTitle} from "@/components/ui/card";
+import { Badge } from "@/components/ui/badge";
+import { VendorResponseTable } from "@/lib/rfq-last/attachment/vendor-response-table"
interface IndexPageProps {
- // Next.js 13 App Router에서 기본으로 주어지는 객체들
params: {
lng: string
id: string
}
- searchParams: Promise<SearchParams>
+ searchParams: Promise<Record<string, any>>
}
export default async function RfqPage(props: IndexPageProps) {
- const resolvedParams = await props.params
- const lng = resolvedParams.lng
+ const resolvedParams = await props.params;
const rfqId = parseInt(resolvedParams.id, 10);
-
+
if (!rfqId || isNaN(rfqId) || rfqId <= 0) {
return (
<div className="p-4">
@@ -35,65 +33,85 @@ export default async function RfqPage(props: IndexPageProps) {
);
}
-
- // 2) SearchParams 파싱 (Zod)
- // - "filters", "page", "perPage", "sort" 등 contact 전용 컬럼
- const searchParams = await props.searchParams;
- const activeTab = searchParams.tab || '설계';
+ // 모든 첨부파일 데이터 가져오기
+ const { data, success } = await getRfqAllAttachments(rfqId);
+ const { vendorData, vendorSuccess } = await getRfqVendorAttachments(rfqId);
+
+ if (!success) {
+ return (
+ <div className="p-4">
+ <Alert variant="destructive">
+ <AlertCircle className="h-4 w-4" />
+ <AlertTitle>오류</AlertTitle>
+ <AlertDescription>
+ 데이터를 불러오는데 실패했습니다.
+ </AlertDescription>
+ </Alert>
+ </div>
+ );
+ }
- // 활성 탭에 따라 다른 파라미터 파싱
- const designSearch = activeTab === '설계'
- ? searchParamsRfqAttachmentsCache.parse({
- ...searchParams,
- // design_ prefix가 붙은 파라미터들 추출
- page: searchParams.design_page,
- perPage: searchParams.design_perPage,
- sort: searchParams.design_sort,
- filters: searchParams.design_filters,
- })
- : { page: 1, perPage: 10, sort: [], filters: [] };
-
- const purchaseSearch = activeTab === '구매'
- ? searchParamsRfqAttachmentsCache.parse({
- ...searchParams,
- // purchase_ prefix가 붙은 파라미터들 추출
- page: searchParams.purchase_page,
- perPage: searchParams.purchase_perPage,
- sort: searchParams.purchase_sort,
- filters: searchParams.purchase_filters,
- })
- : { page: 1, perPage: 10, sort: [], filters: [] };
-
- // 활성 탭의 데이터만 실제로 가져오기
- const [designData, purchaseData] = await Promise.all([
- activeTab === '설계'
- ? getRfqLastAttachments({ ...designSearch }, rfqId, "설계")
- : { data: [], pageCount: 0 },
- activeTab === '구매'
- ? getRfqLastAttachments({ ...purchaseSearch }, rfqId, "구매")
- : { data: [], pageCount: 0 }
- ]);
-
-
- // 4) 렌더링
return (
<div className="space-y-6">
<div>
- <h3 className="text-lg font-medium">
- 견적 RFQ 문서관리
- </h3>
+ <h3 className="text-lg font-medium">견적 RFQ 문서관리</h3>
<p className="text-sm text-muted-foreground">
설계로부터 받은 RFQ 문서와 구매 RFQ 문서를 관리하고 Vendor 회신을 점검/관리하는 화면입니다.
</p>
</div>
<Separator />
- <div>
- <RfqAttachmentsTable
- rfqId={rfqId}
- initialDesignData={designData}
- initialPurchaseData={purchaseData}
- />
- </div>
+
+ {/* 구매자 → 벤더 문서 섹션 */}
+ <Card>
+ <CardHeader>
+ <div className="flex items-center justify-between">
+ <div className="space-y-1">
+ <CardTitle className="text-base font-semibold">
+ RFQ 발송 문서
+ </CardTitle>
+ <CardDescription>
+ 구매자가 벤더에게 발송하는 견적 요청 문서
+ </CardDescription>
+ </div>
+ <Badge variant="outline" className="font-mono">
+ <ArrowRight className="h-3 w-3 mr-1" />
+ To Vendor
+ </Badge>
+ </div>
+ </CardHeader>
+ <CardContent>
+ <RfqAttachmentsTable
+ rfqId={rfqId}
+ initialData={data}
+ />
+ </CardContent>
+ </Card>
+
+ {/* 벤더 → 구매자 문서 섹션 */}
+ <Card>
+ <CardHeader>
+ <div className="flex items-center justify-between">
+ <div className="space-y-1">
+ <CardTitle className="text-base font-semibold">
+ 벤더 회신 문서
+ </CardTitle>
+ <CardDescription>
+ 벤더가 구매자에게 회신한 견적 및 기술 문서
+ </CardDescription>
+ </div>
+ <Badge variant="outline" className="font-mono">
+ <ArrowLeft className="h-3 w-3 mr-1" />
+ From Vendor
+ </Badge>
+ </div>
+ </CardHeader>
+ <CardContent>
+ <VendorResponseTable
+ rfqId={rfqId}
+ initialData={vendorData}
+ />
+ </CardContent>
+ </Card>
</div>
- )
+ );
} \ No newline at end of file